#!/usr/bin/env bash

# mlaine@sdfeu

source '../say.sh'

nick="$1"
args=("${@:3}")

if [[ "${#args[@]}" -ge 2 && "${args[-2]}" = '>' &&
    ! "${args[-1]}" =~ '#' ]]; then
    ch="${args[-1]}"
else
    ch="$nick"
fi

msg=(
    '/*'
    'Hi there! I am the sdf irc network bot. I provide'
    'several useful commands; please take a moment to read'
    'the following few lines.'
    ' '
    'You may view answers to frequently asked questions by'
    "using the '!faq' command. Without arguments it lists"
    'the available topics, of which you can supply one as'
    'an argument to the command.'
    ' '
    "All available commands can be listed with '!commands'."
    'In order to avoid spamming on channels, PLEASE do'
    'experiment with the commands via private messages,'
    'i.e., /msg BASHy2[-EU]. Any questions left unanswered'
    'are welcomed in #helpdesk.'
    ' '
    "IF YOU FORGOT YOUR PASSWORD ISSUE '!faq forgot'."
    ' '
    'This message is sent on join to anyone who has not'
    'been active on any channel BASHy2[-EU] is on.'
    '*/'
)

say "$ch" "${msg[@]}" 

